<?php
/*
Description: This file is used to change login paassword.
*/
#########IncludeFiles####################################################################################
include_once '../inc/config.php';
include_once("../inc/bootstrape.php");
require_once _SITE_PATH_.'classes/Vendor/Vendor.php';
require_once _SITE_PATH_.'classes/Honeymoon/Honeymoon.php';
require_once _SITE_PATH_.'classes/CommonUtility/CommonUtility.php';

//	END CHANGE PASSWORD CODE	//
$errMsg = $_GET['err'];
$action = trim($_REQUEST['action']);
$id = trim($_REQUEST['id']); 
if(empty($id)){
    header("Location: "._SITE_ADMIN_URL_."honeymoon-package/package_mng.php");
    exit;
}
$result = Honeymoon::getPackageById($id);
if(isset($_POST['submit'])){
	$parms['vendor_id'] = $_POST['vendor_id'];
    $parms['title'] = $_POST['title'];
    $parms['theme_id'] = $_POST['theme_id'];
    $parms['package_url'] = $_POST['package_url'];
    $parms['days'] = $_POST['days'];
    $parms['tags'] = $_POST['tags'];
    $parms['price_per_couple'] = $_POST['price_per_couple'];
    $parms['short_description'] = $_POST['short_description'];
    $parms['description'] = $_POST['description'];
    if(!empty($_POST['destinations'])){
		$parms['destinations'] = implode(',',$_POST['destinations']);
	}
    $parms['package_type'] = $_POST['package_type'];
    $parms['cancellation_policy'] = $_POST['cancellation_policy'];
    $parms['booking_amount'] = $_POST['booking_amount'];
    
     // upload and create thumb of the image //
    if( !empty( $_FILES['package_image'] ) ){
        $filename  = 'package_image';     //  this is name of the control you are using in html form         
        $module='honeymoon_pkg';
        $uploadedfile = CommonUtility::uploadNcreateThumb($filename, $module, true, 100);
        if( $uploadedfile!= -1 )    {
            $parms['image'] = $uploadedfile;//$_POST['package_image'];
        }
        CommonUtility::removeImage($result['image'], $module); 
    }
    
    $condition = array(); 
    $condition['id'] = $id;
    if( CommonUtility::updateData($parms, 'honeymoon_package', $condition)) {        
        header("Location: package_mng.php?msg=1006");            
        exit;
    }
    $errMsg = 1007;    
}
if( $errMsg ){
    $result = $_POST;
    
}else{                
    $result['destinations'] = explode(',',$result['destinations']);
}
$dropdown_cities = array();
$dropdown_cities = CommonUtility::getCity('', $result['destinations']);

$_tplName = 'honeymoon-package/package_edit.tpl';
$_title = 'Edit Honeymoon Package';
require_once _ADMIN_TPL_MAIN_;
?>